package com.wzb.mybatisplus.bitaction.electrumaction.one;

import java.util.List;

public class BitcoinExample {
    public static void main(String[] args) {
        String address = "1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj"; // 比特币创始区块地址

        // 查询余额
        double balance = BitcoinService.getBalance(address);
        System.out.println("=== 比特币余额查询 ===");
        System.out.println("地址: " + address);
        System.out.println("余额: " + balance + " BTC");
        System.out.println();

        // 查询最近交易记录
        System.out.println("=== 最近交易记录 ===");
        List<BitcoinTransaction> transactions = BitcoinService.getTransactions(address, 10);

        for (BitcoinTransaction tx : transactions) {
            System.out.println(tx);
        }

        // 统计信息
        System.out.println();
        System.out.println("=== 统计信息 ===");
        long incoming = transactions.stream()
                .filter(tx -> "IN".equals(tx.getDirection()))
                .count();
        long outgoing = transactions.stream()
                .filter(tx -> "OUT".equals(tx.getDirection()))
                .count();

        System.out.println("总交易数: " + transactions.size());
        System.out.println("收入交易: " + incoming);
        System.out.println("支出交易: " + outgoing);
    }
}